package com.kx.center.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.kx.center.entity.Store;
import com.kx.center.service.StoreService;
import com.kx.center.util.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;

@Controller
@RequestMapping("/store")
public class StoreController {
	
	@Autowired
	private StoreService service;

	@RequestMapping(value = "list", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@ResponseBody
	public String list(HttpServletRequest request) throws JsonProcessingException {
		List<Store> list = service.findAllStore();
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("data", list);
		return Response.success(map);
	}

}
